package com.flymobi.admin;

import java.io.IOException;
import java.util.TimeZone;

import org.apache.log4j.Logger;

import com.flymobi.util.WebContext;
import com.flymobi.util.WebUtil;
import com.opensymphony.xwork2.ActionSupport;

/**
 * 
 * 
 * Title:
 * 
 * Description:
 * 
 * Copyright: Copyright (c) 2008
 * 
 * @author haoxz11
 * @created Jun 19, 2008 6:23:01 AM
 * @version $Id: BaseAction.java,v 1.1 2010/04/09 03:27:16 airsou Exp $
 */
public abstract class BaseAction extends ActionSupport {
	protected static Logger log = Logger.getLogger(BaseAction.class);
	/**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;

	public String execute() {
		TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
		WebContext context = WebUtil.getContext();
		String af = process(context);
		if (af != null) {
			if(af.indexOf("/")>=0){
				try {
					context.getResponse().sendRedirect(af);
				} catch (IOException e) {
					e.printStackTrace();
				}
				return null;
			}
		}
		return af;
	}

	public abstract String process(WebContext context);
	
	public boolean emptyId(String id){
		boolean flag=false;
		if(null==id||"".equals(id)||"null".equals(id)||"0".equals(id)){
			flag=true;
		}
		return flag;
	}
}